/*
 * platform.h : header files and specific flags for each platform SWL is
 * running on.
 *
 * Written by T.Pierron, Mar 26, 2006.
 */

#ifndef	PLATFORM_H
#define	PLATFORM_H

#define	STRICT
#define	UNICODE
#define	WIN32_LEAN_AND_MEAN
#define	WINVER        0x500
#define	_WIN32_IE     0x501
#define	_WIN32_WINNT  0x0501
#include <windows.h>
#include <windowsx.h>
#include <commctrl.h>
#include <commdlg.h>
#include <shlobj.h>
#include <malloc.h>

/* Dynamicly loaded symbols */
typedef WINAPI HRESULT (*pfnCSOH)(HGLOBAL,BOOL,LPSTREAM*);
typedef WINAPI PVOID (*pfnCTMA)(ULONG);
typedef WINAPI void  (*pfnCTMF)(PVOID);
typedef WINAPI BOOL  (*pfnGSFN)(LPOPENFILENAMEW);
typedef WINAPI BOOL  (*pfnGOFN)(LPOPENFILENAMEW);
typedef WINAPI BOOL  (*pfnChCo)(LPCHOOSECOLORW);
typedef WINAPI BOOL  (*pfnChFo)(LPCHOOSEFONTW);
typedef WINAPI BOOL  (*pfnAlBl)(HDC,int,int,int,int,HDC,int,int,int,int,BLENDFUNCTION);
typedef WINAPI BOOL  (*pfnILDe)(HIMAGELIST);
typedef WINAPI BOOL  (*pfnILRe)(HIMAGELIST,int);
typedef WINAPI int   (*pfnILAd)(HIMAGELIST,HBITMAP,HBITMAP);
typedef WINAPI BOOL  (*pfnILDr)(HIMAGELIST,int,HDC,int,int,UINT);
typedef WINAPI int   (*pfnILGC)(HIMAGELIST);
typedef WINAPI BOOL  (*pfnILGI)(HIMAGELIST,int,IMAGEINFO *);
typedef WINAPI HIMAGELIST (*pfnILCe)(int,int,UINT,int,int);
typedef WINAPI BOOL  (*pfnGrFi)(HDC,PTRIVERTEX,ULONG,PVOID,ULONG,ULONG);
typedef WINAPI BOOL  (*pfnILRP)(HIMAGELIST,int,HBITMAP,HBITMAP);
typedef WINAPI BOOL  (*pfnIsTA)(void);

extern pfnCSOH pCreateStreamOnHGlobal;
extern pfnILAd pImageList_Add;
extern pfnILCe pImageList_Create;
extern pfnILDe pImageList_Destroy;
extern pfnILRe pImageList_Remove;
extern pfnILDr pImageList_Draw;
extern pfnILGI pImageList_GetImageInfo;
extern pfnILGC pImageList_GetImageCount;
extern pfnILRP pImageList_Replace;
extern pfnCTMA pCoTaskMemAlloc;
extern pfnCTMF pCoTaskMemFree;
extern pfnGSFN pGetSaveFileName;
extern pfnGOFN pGetOpenFileName;
extern pfnChCo pChooseColor;
extern pfnChFo pChooseFont;
extern pfnAlBl pAlphaBlend;
extern pfnGrFi pGradientFill;
extern pfnIsTA pIsThemeActive;

// Not defined in MinGW :-/
#ifndef	TBN_GETINFOTIP
#define TBN_GETINFOTIP (TBN_FIRST-19)
#endif

#ifndef	COLOR_MENUBAR
#define	COLOR_MENUBAR  30
#endif

#ifndef	COLOR_MENUHILIGHT
#define	COLOR_MENUHILIGHT 29
#endif

#ifndef	CSS_VERT
#define	CSS_VERT     0x80
#endif

#ifndef	ODS_NOFOCUSRECT
#define	ODS_NOFOCUSRECT   0x0200
#endif

#ifndef	HDF_SORTUP
#define	HDF_SORTUP     0x400
#define	HDF_SORTDOWN   0x200
#endif

#ifndef	LV_VIEW_TILE
#define	LV_VIEW_TILE   0x4
#endif

#ifndef	TTI_INFO
#define	TTI_NONE      0
#define	TTI_INFO      1
#define	TTI_WARNING   2
#define	TTI_ERROR     3
#endif

#ifndef	CF_DIBV5
#define CF_DIBV5      17
#endif

#ifndef TTM_SETTITLE
#define	TTM_SETTITLE    WM_USER + 32
#endif

#ifndef	BCM_SETIMAGELIST
#define	BCM_SETIMAGELIST                0x1600 + 2
#define	BUTTON_IMAGELIST_ALIGN_LEFT     0
#define	BUTTON_IMAGELIST_ALIGN_RIGHT    1
#define	BUTTON_IMAGELIST_ALIGN_TOP      2
#define	BUTTON_IMAGELIST_ALIGN_BOTTOM   3
#define	BUTTON_IMAGELIST_ALIGN_CENTER   4
typedef struct {
  HIMAGELIST himl;
  RECT       margin;
  UINT       uAlign;
} BUTTON_IMAGELIST, *PBUTTON_IMAGELIST;
#endif

#ifdef GDIPLUS_DEF
typedef struct {
   UINT32 GdiplusVersion;
   LPVOID DebugEventCallback;
   BOOL SuppressBackgroundThread;
   BOOL SuppressExternalCodecs;
} GdiplusStartupInput;

typedef struct {
   LPVOID NoticationHook;
   LPVOID NotificatoinUnhook;
} GdiplusStartupOutput;

typedef void GpImage; // opaque type

typedef struct {
   UINT Width;
   UINT Height;
   INT Stride;
   int PixelFormat;
   VOID* Scan0;
   UINT_PTR Reserved;
} GpBitmapData;

typedef struct {
   GpImage* nativeImage;
   int lastResult;
   int loadStatus;
} GpBitmap;

// from GdiplusTypes.h
typedef struct {
   INT X;
   INT Y;
   INT Width;
   INT Height;
} GpRect;

typedef WINAPI int (*GdiplusStartupProc)(ULONG_PTR *token, const GdiplusStartupInput* input, GdiplusStartupOutput* output);
typedef WINAPI int (*GdiplusShutdownProc)(ULONG_PTR token);
typedef WINAPI int (*GdipCreateBitmapFromStreamProc)(IStream* stream, GpBitmap **bitmap);
typedef WINAPI int (*GdipDisposeImageProc)(GpImage *image);
typedef WINAPI int (*GdipBitmapLockBitsProc)(GpBitmap* bitmap, const GpRect* rect, int flags, int format, GpBitmapData* lockedBitmapData);

typedef WINAPI int (*GdipBitmapUnlockBitsProc)(GpBitmap* bitmap, GpBitmapData* lockedBitmapData);


#endif
#endif
